package com.iot.inter.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author: songgt
 * @date: 2018-09-08 10:46
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * 读取application.yml配置文件中对swagger的配置
     */
    @Value("${swagger2.host}")
    private String host;

    @Bean
    public Docket createLogin1() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("2.0接口")
                .host(host)
                //.host("wx.linksfield.net")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.iot.inter.controller.newinterface"))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("领科接口网关")
                .description("")
                .version("1.0")
                .termsOfServiceUrl("https://wx.linksfield.net/iot")
                .contact(new Contact("", "", ""))
                .build();
    }

}
